<template>
  <div style="width:100%;overflow-x:hidden">
    <weui-input :list="input_0_list" title="" more_label="" agreement_name="" :tips="null">
      <weui-button slot="button" type="primary" @on-click="on_button_0_click">修改</weui-button>
    </weui-input>
  </div>
</template>

<script>
  import WeuiInput from '../vue2componentSet/src/components/WeuiInput'
  import WeuiButton from '../vue2componentSet/src/components/WeuiButton'
  import global from '../lib/global'
  import axios from 'axios'

  export default {
    components: {
      WeuiInput,
      WeuiButton
    },
    data() {
      return {
        input_0_list: [{
          label: '密码',
          type: 'password',
          value: ''
        }]
      }
    },
    methods: {
      on_button_0_click() {
        axios.post(global.server + 'setPassword.do', {
          password: require('md5')(this.input_0_list[0].value)
        }).then(result => {
          var obj = result.data
          if (obj.result == 1) {
            this.$router.goback()
            this.$store.commit('toast', {
              type: 'success',
              content: '修改密码成功'
            })
          }
        }, result => {
          console.log(result)
        })
      }
    },
    mounted() {
      this.$store.commit('set_title', '设置密码')

      if (!this.$store.state.customer) {
        this.$router.goback()
        return
      }
    }
  }
</script>
